home *** CD-ROM | disk | FTP | other *** search
/ The Big Day - Work Smarter - Learn How / The Big Day - Work Smarter - Learn How (Microsoft).BIN / Certification / Microsoft Certified Professional Web site - MCSE + Internet_file / toolbar.js < prev   
Text File  |  2000-04-16  |  20KB  |  670 lines

  1. // VSS Version 67 - Release October 25, 1999
  2. //
  3. var ToolBar_Supported = false;
  4. var Frame_Supported   = false;
  5. var DoInstrumentation = false;
  6.  
  7. if (navigator.userAgent.indexOf("MSIE")    != -1 && 
  8.     navigator.userAgent.indexOf("Windows") != -1 && 
  9.     navigator.appVersion.substring(0,1) > 3)
  10. {
  11.     ToolBar_Supported = true;
  12. }
  13.  
  14. if (ToolBar_Supported)
  15. {
  16.     var newLineChar = String.fromCharCode(10);
  17.     var char34 = String.fromCharCode(34);
  18.     var LastMSMenu = "";
  19.     var LastICPMenu= "";
  20.     var CurICPMenu = "";
  21.     var IsMSMenu = false;
  22.     var IsMenuDropDown = true;
  23.     var HTMLStr;
  24.     var TBLStr;
  25.     var x = 0;
  26.     var y = 0;
  27.     var x2 = 0;
  28.     var y2 = 0;
  29.     var x3 = 0;
  30.     var MSMenuWidth;
  31.     var ToolbarMinWidth;
  32.     var ToolbarMenu;
  33.     var ToolbarBGColor;
  34.     var ToolbarLoaded = false;
  35.     var aDefMSColor  = new Array(3);
  36.     var aDefICPColor = new Array(3);
  37.     var aCurMSColor  = new Array(3);
  38.     var aCurICPColor = new Array(3);
  39.     var MSFont;
  40.     var ICPFont;
  41.     var MaxMenu = 30;
  42.     var TotalMenu = 0;
  43.     var arrMenuInfo = new Array(30);
  44.  
  45.     // Output style sheet and toolbar ID
  46.     document.write("<SPAN ID='StartMenu' STYLE='display:none;'></SPAN>");
  47.  
  48.     // Build toolbar template
  49.     TBLStr  = "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR STYLE='height:20;vertical-align:middle'><!--ICP_MENU_TITLES--></TR></TABLE>";
  50.     HTMLStr = 
  51.         "<DIV ID='idToolbar'     STYLE='background-color:white;width:100%'>" +
  52.         "<DIV ID='idRow1'        STYLE='position:relative;height:20;'>" +
  53.         "<DIV ID='idICPBanner'   STYLE='position:absolute;top:0;left:0;height:60;width:250;overflow:hidden;vertical-align:top;'><!--BEG_ICP_BANNER--><!--END_ICP_BANNER--></DIV>" +
  54.         "<DIV ID='idMSMenuCurve' STYLE='position:absolute;top:0;left:250;height:20;width:18;overflow:hidden;vertical-align:top;'><IMG SRC='/library/toolbar/images/curve.gif' BORDER=0></DIV>" +
  55.         "<DIV ID='idMSMenuPane'  STYLE='position:absolute;top:0;left:250;height:20;width:10;color:white;background-color:black;float:right;' NOWRAP><!--MS_MENU_TITLES--></DIV>" + 
  56.         "</DIV>" +
  57.         "<DIV ID='idRow2' STYLE='position:relative;left:250;height:40;'>" +
  58.         "<DIV ID='idADSBanner'   STYLE='position:absolute;top:0;left:0;height:40;width:200;vertical-align:top;overflow:hidden;'><!--BEG_ADS_BANNER--><!--END_ADS_BANNER--></DIV>" +
  59.         "<DIV ID='idMSCBanner'   STYLE='position:absolute;top:0;left:200;height:40;width:112;vertical-align:top;overflow:hidden;' ALIGN=RIGHT><!--BEG_MSC_BANNER--><!--END_MSC_BANNER--></DIV>" +
  60.         "</DIV>" +
  61.         "<DIV ID='idRow3' STYLE='position:relative;height:20;width:100%'>" +
  62.         "<DIV ID='idICPMenuPane' STYLE='position:absolute;top:0;left:0;height:20;color:white;background-color:black;' NOWRAP><!--ICP_MENU_TITLES--></DIV>" +
  63.         "</DIV>" +
  64.         "</DIV>" +
  65.         "<SCRIPT FOR=idToolbar EVENT=onresize>resizeToolbar();</SCRIPT>" +
  66.         "<SCRIPT FOR=idToolbar EVENT=onmouseover>hideMenu();</SCRIPT>" +
  67.         "<SCRIPT TYPE='text/javascript'>" + 
  68.         "   var ToolbarMenu = StartMenu;" + 
  69.         "</SCRIPT>" + 
  70.         "<DIV WIDTH=100%>";
  71.  
  72.     // Intialize global variables
  73.     ToolbarBGColor    = "white";                        // toolbar background color
  74.     MSFont  = "xx-small Verdana";
  75.     ICPFont = "bold xx-small Verdana";
  76.     
  77.     aDefMSColor[0]    = aCurMSColor[0]  = "black";    // bgcolor;
  78.     aDefMSColor[1]    = aCurMSColor[1]  = "white";    // text font color
  79.     aDefMSColor[2]  = aCurMSColor[2]  = "red";        // mouseover font color
  80.     
  81.     aDefICPColor[0]    = aCurICPColor[0] = "#6699CC";    // bgcolor;
  82.     aDefICPColor[1] = aCurICPColor[1] = "white";    // text font color
  83.     aDefICPColor[2] = aCurICPColor[2] = "red";        // mouseover font color
  84. }
  85.  
  86. // The hard-coded numbers in functions - drawToolbar() & resizeToolbar()
  87. // correspond to the dimension of the four gif files:
  88. //        ICP_BANNER: 60h x 250w
  89. //        ADS_BANNER: 40h x 200w
  90. //        MSC_BANNER: 40h x 112w
  91. //        Curve:        20h x 18w
  92.  
  93. function drawToolbar()
  94. {
  95.     HTMLStr += "</DIV>";
  96.     document.write(HTMLStr);
  97.     ToolbarLoaded = true;
  98.     MSMenuWidth     = Math.max(idMSMenuPane.offsetWidth, (200+112));
  99.     ToolbarMinWidth = (250+18) + MSMenuWidth;
  100.  
  101.     idToolbar.style.backgroundColor     = ToolbarBGColor;
  102.     idMSMenuPane.style.backgroundColor  = aDefMSColor[0];
  103.     idICPMenuPane.style.backgroundColor = aDefICPColor[0];
  104.     idMSMenuPane.style.color            = aDefMSColor[1];
  105.     idICPMenuPane.style.color            = aDefICPColor[1];
  106.     resizeToolbar();
  107.  
  108.     for (i = 0; i < TotalMenu; i++) 
  109.     {
  110.         thisMenu = document.all(arrMenuInfo[i].IDStr);
  111.         if (thisMenu != null)
  112.         {
  113.             if (arrMenuInfo[i].IDStr == LastMSMenu && arrMenuInfo[i].type == "R")
  114.             {
  115.                 //Last MSMenu has to be absolute width
  116.                 arrMenuInfo[i].type = "A";
  117.                 arrMenuInfo[i].unit = 200;
  118.             }
  119.             if (arrMenuInfo[i].type == "A")
  120.                 thisMenu.style.width = arrMenuInfo[i].unit;
  121.             else 
  122.                 thisMenu.style.width = Math.round(arrMenuInfo[i].width * arrMenuInfo[i].unit) + 'em';
  123.         }
  124.     }
  125. }
  126.  
  127. function resizeToolbar()
  128. {
  129.     if (ToolBar_Supported == false) return;
  130.  
  131.     w = Math.max(ToolbarMinWidth, document.body.clientWidth) - ToolbarMinWidth;
  132.     
  133.     idMSMenuCurve.style.left  = (250+w);
  134.     idMSMenuPane.style.left   = (250+w+18);
  135.     idMSMenuPane.style.width  = MSMenuWidth;
  136.  
  137.     idADSBanner.style.left    = (w+18);
  138.  
  139.     idMSCBanner.style.left    = (w+18+200);
  140.     idMSCBanner.style.width   = (MSMenuWidth - 200);
  141.     
  142.     idICPMenuPane.style.width = ToolbarMinWidth + w;
  143. }
  144.  
  145. function setToolbarBGColor(color)
  146. {    
  147.     ToolbarBGColor = color;
  148.     if (ToolbarLoaded == true)
  149.         idToolbar.style.backgroundColor = ToolbarBGColor;
  150. }    
  151.  
  152. function setMSMenuFont(sFont)
  153. {    MSFont = sFont;
  154. }
  155.  
  156. function setICPMenuFont(sFont)
  157. {    ICPFont = sFont;
  158. }
  159.  
  160. function setDefaultMSMenuColor(bgColor, fontColor, mouseoverColor)
  161. {    
  162.     if (bgColor   != "")      aDefMSColor[0] = bgColor;
  163.     if (fontColor != "")      aDefMSColor[1] = fontColor;
  164.     if (mouseoverColor != "") aDefMSColor[2] = mouseoverColor;
  165. }
  166.  
  167. function setDefaultICPMenuColor(bgColor, fontColor, mouseoverColor)
  168. {    
  169.     if (bgColor   != "")      aDefICPColor[0] = bgColor;
  170.     if (fontColor != "")      aDefICPColor[1] = fontColor;
  171.     if (mouseoverColor != "") aDefICPColor[2] = mouseoverColor;
  172. }
  173.  
  174. function setICPMenuColor(MenuIDStr, bgColor, fontColor, mouseoverColor)
  175. {    
  176.     if (ToolbarLoaded == false) return;
  177.  
  178.     // Reset previous ICP Menu color if any
  179.     if (CurICPMenu != "")
  180.     {
  181.         PrevID = CurICPMenu.substring(4);
  182.         CurICPMenu = "";
  183.         setICPMenuColor(PrevID, aDefICPColor[0], aDefICPColor[1], aDefICPColor[2]);
  184.     }
  185.  
  186.     var    id = "AM_" + "ICP_" + MenuIDStr;
  187.     var thisMenu = document.all(id);
  188.     if (thisMenu != null)
  189.     {
  190.         CurICPMenu = "ICP_" + MenuIDStr;
  191.         aCurICPColor[0] = bgColor;
  192.         aCurICPColor[1] = fontColor;
  193.         aCurICPColor[2] = mouseoverColor;
  194.  
  195.         // Change menu color
  196.         if (bgColor != "")
  197.             thisMenu.style.backgroundColor = bgColor;
  198.         if (fontColor != "")
  199.             thisMenu.children(0).style.color = fontColor;
  200.  
  201.         // Change subMenu color
  202.         id = "ICP_" + MenuIDStr;
  203.         thisMenu = document.all(id);
  204.         if (thisMenu != null)
  205.         {
  206.             if (bgColor != "")
  207.                 thisMenu.style.backgroundColor = bgColor;
  208.             
  209.             if (fontColor != "")
  210.             {
  211.                 i = 0;
  212.                 id = "AS_" + "ICP_" + MenuIDStr;
  213.                 thisMenu = document.all.item(id,i);
  214.                 while (thisMenu != null)
  215.                 {
  216.                     thisMenu.style.color = fontColor;
  217.                     i += 1;
  218.                     thisMenu = document.all.item(id,i);
  219.                 }
  220.             }
  221.         }
  222.     }
  223. }
  224.  
  225. function setAds(Gif,Url,AltStr)
  226. {    setBanner(Gif,Url,AltStr,"<!--BEG_ADS_BANNER-->","<!--END_ADS_BANNER-->");
  227. }
  228.  
  229. function setICPBanner(Gif,Url,AltStr)
  230. {    setBanner(Gif,Url,AltStr,"<!--BEG_ICP_BANNER-->","<!--END_ICP_BANNER-->");
  231. }
  232.  
  233. function setMSBanner(Gif,Url,AltStr)
  234. {    tempGif = "/library/toolbar/images/" + Gif;
  235.     setBanner(tempGif,Url,AltStr,"<!--BEG_MSC_BANNER-->","<!--END_MSC_BANNER-->");
  236. }
  237.  
  238. function setBanner(BanGif, BanUrl, BanAltStr, BanBegTag, BanEndTag)
  239. {
  240.     begPos = HTMLStr.indexOf(BanBegTag);
  241.     endPos = HTMLStr.indexOf(BanEndTag) + BanEndTag.length;
  242.     
  243.     SubStr = HTMLStr.substring(begPos, endPos);
  244.     SrcStr = "";
  245.     if (BanUrl != "")
  246.         SrcStr += "<A Target='_top' HREF='" + formatURL(BanUrl, BanGif) + "'>";
  247.     SrcStr += "<IMG SRC='" + BanGif + "' ALT='" + BanAltStr + "' BORDER=0>";
  248.     if (BanUrl != "")
  249.         SrcStr += "</A>";
  250.     SrcStr = BanBegTag + SrcStr + BanEndTag;
  251.     HTMLStr = HTMLStr.replace(SubStr, SrcStr);    
  252. }
  253.  
  254. function setICPSubMen